package com.szl.group.utils;

import org.slf4j.Logger;

import java.text.MessageFormat;

/**
 * 日志工具类
 */
public class LoggerUtils {


    public static void debug(Logger logger, String info, Object... params) {
        if(logger == null){
            return;
        }
        if (logger.isDebugEnabled()) {
            logger.debug(format(info, params));
        }
    }

    public static void info(Logger logger, String info, Object... params) {
        if(logger == null){
            return;
        }
        if (logger.isInfoEnabled()) {
            logger.info(format(info, params));
        }
    }

    public static void warn(Logger logger, String info, Object... params) {
        if(logger == null){
            return;
        }
        if (logger.isWarnEnabled()) {
            logger.warn(format(info, params));
        }
    }

    public static void error(Logger logger, String info, Object... params) {
        if(logger == null){
            return;
        }
        if (logger.isErrorEnabled()) {
            logger.error(format(info, params));
        }
    }

    private static String format(String pattern, Object... arguments) {
        return MessageFormat.format(pattern, arguments);
    }
}
